module ctz16(
  input  [15:0] in,
  output [ 4:0] out
);

reg out;

always @* begin
  casez (in)
    16'b???????????????1: out = 5'd0;
    16'b??????????????10: out = 5'd1;
    16'b?????????????100: out = 5'd2;
    16'b????????????1000: out = 5'd3;
    16'b???????????10000: out = 5'd4;
    16'b??????????100000: out = 5'd5;
    16'b?????????1000000: out = 5'd6;
    16'b????????10000000: out = 5'd7;
    16'b???????100000000: out = 5'd8;
    16'b??????1000000000: out = 5'd9;
    16'b?????10000000000: out = 5'd10;
    16'b????100000000000: out = 5'd11;
    16'b???1000000000000: out = 5'd12;
    16'b??10000000000000: out = 5'd13;
    16'b?100000000000000: out = 5'd14;
    16'b1000000000000000: out = 5'd15;
    16'b0000000000000000: out = 5'd16;
  endcase
end

endmodule
